//
//  PushViewController.swift
//  PlayGround
//
//  Created by admin on 2021/9/17.
//

import Foundation
import UIKit
protocol PushViewController {
    func selectvalue()->Any
}

class PushView: SettingInputView {
    
    lazy var input: UIImageView = {
        let aview = UIImageView()
        aview.image = .init(systemName: "chevron.forward")
        return aview
    }()
    lazy var vlaueLab: UILabel = {
        let aview = UILabel()
        aview.textColor = .darkText
        return aview
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(titleLab)
        addSubview(input)
        addSubview(vlaueLab)
    }
    override func updateUI() {
        if let push = data?.value as? PushViewController{
            vlaueLab.text = "\(push.selectvalue())"
        }else{
            vlaueLab.text = "\(self)"
        }
    }
    override var value:Any{
        input.resignFirstResponder()
        if let push = data?.value as? PushViewController{
            return push.selectvalue()
        }else{
            return "\(self)"
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLab.snp.makeConstraints { snp in
            snp.left.equalToSuperview().offset(10)
            snp.centerY.equalToSuperview()
        }
        input.snp.makeConstraints { snp in
            snp.right.equalToSuperview().offset(-10)
            snp.centerY.equalToSuperview()
        }
        vlaueLab.snp.makeConstraints { snp in
            snp.right.equalTo(input.snp.left).offset(-10)
            snp.centerY.equalToSuperview()
        }
    }
}
extension UIViewController:PushViewController{
    func selectvalue() -> Any {
        return "push"
    }

    
}
